package com.wehealth.biz_ecg.dialog

import android.bluetooth.BluetoothDevice
import android.view.Gravity
import android.view.LayoutInflater
import android.view.WindowManager
import com.wehealth.biz_ecg.R
import com.wehealth.biz_ecg.adapter.BlueToothDeviceListAdapter
import com.wehealth.biz_ecg.databinding.DialogLayoutDeivceListBinding
import com.wehealth.three.lib_connect.base.BaseBottomDialog

class BlueToothDeviceListDialog(
    val list: List<BluetoothDevice>,
    val searchAction: () -> Unit,
    val connectAction: (device: BluetoothDevice) -> Unit
) :
    BaseBottomDialog<DialogLayoutDeivceListBinding>() {
    override fun getLayoutId(): Int {
        return R.layout.dialog_layout_deivce_list
    }

    override fun widthLayoutManager(): Int {
        return WindowManager.LayoutParams.MATCH_PARENT
    }

    override fun heightLayoutManager(): Int {
        return WindowManager.LayoutParams.MATCH_PARENT
    }

    override fun setGravity(): Int {
        return Gravity.TOP
    }

    override fun initBinding(inflater: LayoutInflater) {
        val adapter = BlueToothDeviceListAdapter(this, list, connectAction)
        dataBinding?.dialogDeviceList?.adapter = adapter
        adapter.notifyDataSetChanged()
        dataBinding?.dialogDeviceListResearch?.setOnClickListener {
            searchAction.invoke()
        }

    }


}